﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ThermalEquipmentDesign.Model;
using System.Windows.Input;
using System.Windows;
using ThermalEquipmentDesign.Model.Condenser.HorizontalPipeR12;
using ThermalEquipmentDesign.Reference_Path;
using ThermalEquipmentDesign.Reference_Path.Condenser;

namespace ThermalEquipmentDesign.ViewModel.Condenser
{
    public class HorizontalPipeR12ViewModel : ObservableObject
    {
        // Declare fields for binding
        #region fields for binding
        private HorizontalPipeR12 ohorizontalPipeR12 = new HorizontalPipeR12();
        private HorizontalPipeR12Result ohorizontalPipeR12Result = new HorizontalPipeR12Result();
        private ICommand calculateHorizontalPipeR12;
        private String stooltip = "Press F1 for Help";
        #endregion

        // Create properties for binding
        #region properties for binding
        public String sTooltip
        {
            get { return stooltip; }
            set { stooltip = value; }
        }

        public HorizontalPipeR12 oHorizontalPipeR12
        {
            get { return ohorizontalPipeR12; }
            set
            {
                if (value != ohorizontalPipeR12)
                {
                    ohorizontalPipeR12 = value;
                    OnPropertyChanged("oHorizontalPipeR12");                    
                }
            }
        }

        public HorizontalPipeR12Result oHorizontalPipeR12Result
        {
            get { return ohorizontalPipeR12Result; }
            set {
                if (value != ohorizontalPipeR12Result)
                {
                    ohorizontalPipeR12Result = value;
                    OnPropertyChanged("oHorizontalPipeR12Result");
                }          
            }
        }

        public ICommand CalculateHorizontalPipeR12
        {
            get
            {
                if (calculateHorizontalPipeR12 == null)
                {
                    calculateHorizontalPipeR12 = new RelayCommand(
                        param => ImplementCalculationHorizontalPipeR12()
                    );
                }
                return calculateHorizontalPipeR12;
            }
        }
        #endregion

        /// <summary>
        /// Calculate design parameter for Horixontal Pipe Condenser
        /// </summary>
        public void ImplementCalculationHorizontalPipeR12()
        {            
            HorizontalPipeR12Model oHorizontalPipeR12Model = new HorizontalPipeR12Model();
            ohorizontalPipeR12Result = oHorizontalPipeR12Model.ImplementCalculation(ohorizontalPipeR12);
        }
        //  Load Reference for the helping
        public void LoadReference(string sIndex)
        {
            System.Windows.Forms.Help.ShowHelp(null, ReferencePath.ReferenceFile, System.Windows.Forms.HelpNavigator.KeywordIndex, HorizontalPipeR12Reference.ResourceManager.GetString(sIndex));
        }
    }
}
    

